<template>
  <div>
    <a-form :labelCol="{ span: 6 }" :wrapperCol="{ span: 18 }">
      <a-form-item required>
        <template slot="label">
          <ZgCheckbox v-model="usernameCk">用户名</ZgCheckbox>
        </template>
        <ZgInput v-model="username"></ZgInput>
      </a-form-item>
      <a-form-item required>
        <template slot="label">
          <ZgCheckbox v-model="passwdCk">密码</ZgCheckbox>
        </template>
        <ZgInput v-model="passwd"></ZgInput>
      </a-form-item>
      <a-form-item required>
        <template slot="label">
          <ZgCheckbox v-model="driverClassNameCk">驱动类</ZgCheckbox>
        </template>
        <ZgInput v-model="driverClassName"></ZgInput>
      </a-form-item>
    </a-form>
  </div>
</template>
<script>
export default {
  props: {
    ids: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      usernameCk: false,
      username: '',
      passwdCk: false,
      passwd: '',
      driverClassNameCk: false,
      driverClassName: ''
    }
  },
  methods: {
    save () {
      if (this.usernameCk === false && this.passwdCk === false && this.driverClassNameCk === false) {
        return this.$result.error('请选择要设置的属性')
      }
      if (this.usernameCk === true && this.username.length === 0) {
        return this.$result.error('请设置用户名')
      }
      if (this.passwdCk === true && this.passwd.length === 0) {
        return this.$result.error('请设置密码')
      }
      if (this.driverClassNameCk === true && this.driverClassName.length === 0) {
        return this.$result.error('请设置驱动类')
      }
      return this.$result.ok({
        idList: this.ids,
        usernameCk: this.usernameCk,
        passwdCk: this.passwdCk,
        driverClassNameCk: this.driverClassNameCk,
        obj: {
          username: this.username,
          passwd: this.passwd,
          driverClassName: this.driverClassName
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
</style>
